package com.example.aixiangshou.runninggame;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.x_memteor.base_master.application.MyApplication;
import com.x_memteor.base_master.base.BaseActivity;
import com.x_memteor.base_master.bean.GameBean;
import com.x_memteor.base_master.bean.ScorBean;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class WinActivity extends BaseActivity {

    @BindView(R.id.imv_win)
    ImageView imvWin;
    @BindView(R.id.tv_win)
    TextView tvWin;
    @BindView(R.id.btn_home)
    Button btnHome;
    @BindView(R.id.btn_again)
    Button btnAgain;
    private int winIcon;
    private int winTime;
    private List<ScorBean> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void initRootView() {
        setContentView(R.layout.activity_win);
    }

    @Override
    public void initView() {
        winIcon = 0;
        winTime = 0;
        list = MyApplication.getInstance().getGameBean().getScorBeanList();
    }

    @Override
    public void initData() {
        for (ScorBean bean : MyApplication.getInstance().getGameBean().getScorBeanList()) {
            if (winTime < bean.getTime()) {
                winTime = bean.getTime();
                winIcon = bean.getIcon();
            }
        }
        imvWin.setImageResource(winIcon);
        MyApplication.getInstance().setGameBean(new GameBean());
    }

    @Override
    public void initListener() {

    }

    @OnClick({R.id.btn_home, R.id.btn_again})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_home:
                startActivity(new Intent(WinActivity.this,WelcomeActivity.class));
                finish();
                break;
            case R.id.btn_again:
                startActivity(new Intent(WinActivity.this,ChooseItemActivity.class));
                finish();
                break;
        }
    }
}
